Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
valueOf
,asEnum
, etc. with old enums toLegacyNamingHelper#convert
.#name/toString
, theElementTag
enum constructor, etc. with old enums toString#valueOf
(since it doesn't contain any explicit method calls on the instance, it doesn't blow up about having the wrong invoke instructions on old versions).Mechanism#requireEnum
with old enums toLegacyNamingHelper#requireType
.VillagerChangesProfessionScriptEvent
: enum constructor ingetContext
(unrelated cleanup).EntityColor#listForEnum
tolistTypes
, and changed it to take a class for the type instead of an enum array, and get the types list from the registry withUtilities#registryKeys
for no-longer-enum types.server.map_cursor_types
now uses different registry-based logic on 1.20+.server.structures
now uses the newUtilities#registryKeys
.Additions
LegacyNamingHelper#convert
- takes in a class and string, and converts that string to the type of the class with either registries or enum conversions.LegacyNamingHelper#requireType
-Mechanism#requireEnum
but for no-longer-enums.Utilities#registryKeys
- returns aListTag
of a registry's keys.Note
Used an
Optional
forLegacyNamingHelper#requireType
, since it just seemed like a good place to use it and have slightly cleaner & maybe faster code using it, with the alternatives beingor
Which are messier, especially when there's a bunch, I.e. in
EntityColor
(and since this is a temporary thing till 1.21 is the min version anyway) - let me know if you'd still prefer one of the other approaches though.Note
Some of these technically have registries on all supported versions, but can't really cleanly make them use these as it'd still involve method calls on interfaces that are enums in older versions - can have a separate set of utils for handling registry stuff in mechs/tags which'll probably be needed anyway as more stuff move to registries, but that's for a different PR.